﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="PictureManage.aspx.cs" Inherits="Hengbei.Web.Admin.PictureManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:EntityDataSource ID="edsPictures" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableFlattening="False"
        EnableInsert="True" EntitySetName="Pictures" EntityTypeFilter="Picture"
        Include="SiteUser, ArticleCategory" EnableDelete="True">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsUsers" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableFlattening="False" EntitySetName="SiteUsers"
        Select="it.[Name], it.[ID]">
    </asp:EntityDataSource>
    <asp:ScriptManager ID="smPictures" runat="server">
    </asp:ScriptManager>
    <asp:EntityDataSource ID="edsCategories" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableFlattening="False" EntitySetName="ArticleCategories">
    </asp:EntityDataSource>
    <div style="text-align: center;">
        <h3>
            图片管理</h3>
    </div>
    <br />
    <br />
    <asp:Label ID="lblInsert" runat="server" CssClass="Label" Text="插入新的图片："></asp:Label>
    <br />
    <asp:DetailsView ID="dvPicture" runat="server" Height="50px" Width="536px" AutoGenerateRows="False"
        CellPadding="4" DataKeyNames="ID" DataSourceID="edsPictures" ForeColor="#333333"
        GridLines="None" DefaultMode="Insert" 
        oniteminserted="dvPicure_ItemInserted" 
        oniteminserting="dvPicture_ItemInserting">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <EditRowStyle BackColor="#999999" />
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <Fields>
            <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" 
                ReadOnly="True" InsertVisible="false"/>
            <asp:BoundField DataField="Name" HeaderText="名称" SortExpression="Name" />
            <asp:TemplateField HeaderText="用户" SortExpression="UserID">
                <InsertItemTemplate>
                   <asp:DropDownList ID="ddlUsers" runat="server" 
                        DataSourceID="edsUsers" DataTextField="Name" DataValueField="ID"
                        SelectedValue='<%# Bind("UserID") %>'></asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="类别" SortExpression="CategoryID">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddlCategories" runat="server" 
                        DataSourceID="edsCategories" DataTextField="Description" DataValueField="ID"
                        SelectedValue='<%# Bind("CategoryID") %>'></asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Description" HeaderText="描述" 
                SortExpression="Description" />
            <asp:TemplateField HeaderText="URL" SortExpression="URL">
                <InsertItemTemplate>
                    <asp:FileUpload ID="fuPicture" runat="server" />
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowInsertButton="True" InsertText="插入" 
                ShowCancelButton="False" />
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:DetailsView>
    <br />
    <asp:UpdatePanel ID="upPictures" runat="server">
        <ContentTemplate>
            <asp:Label ID="lblManage" runat="server" CssClass="Label" Text="管理已有图片："></asp:Label>
            <br />
            <asp:GridView ID="gvPicures" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="edsPictures" CellPadding="4"
                ForeColor="#333333" GridLines="None" Width="100%"
                onrowdatabound="gvPicures_RowDataBound">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" DeleteText="删除" />
                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                        SortExpression="ID" Visible="False" />
                    <asp:BoundField DataField="Name" HeaderText="名称" SortExpression="Name" />
                   <asp:TemplateField HeaderText="用户" SortExpression="SiteUser.Name">
                        <ItemTemplate>
                            <asp:Label ID="lblRole" runat="server" Text='<%# Eval("SiteUser.Name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="类别" SortExpression="ArticleCategory.Description">
                        <ItemTemplate>
                            <asp:Label ID="lblRole" runat="server" Text='<%# Eval("ArticleCategory.Description") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Description" HeaderText="描述" 
                        SortExpression="Description" />
                    <asp:TemplateField HeaderText="缩略图">
                        <ItemTemplate>
                            <asp:HyperLink ID="hlTumb" runat="server" NavigateUrl='<%# Eval("URL") %>' 
                                ImageUrl='<%# Eval("ThumbURL") %>' Target="_blank"></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="URL" HeaderText="图片URL" SortExpression="URL" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
